import { STYLES } from "../config/styles";
import { UI_STRINGS } from "../config/strings";
type Props = {
  files: File[];
  url: string;
};

export function FileList({ files, url }: Props) {
  // 2. 更新渲染逻辑
  const hasFiles = files.length > 0;
  const hasUrl = url.length > 0;

  if (!hasFiles && !hasUrl) {
    return null; // 如果两者都为空，不渲染
  }

  return (
    <div className="my-4">
      <h3 className="font-semibold text-lg mb-2">
        {hasUrl ? "导入的仓库" : "已选择的文件"}
      </h3>
      <div className="bg-gray-50 border rounded-md p-3 max-h-48 overflow-y-auto">
        {hasUrl ? (
          // 3. 显示 URL
          <p className="text-sm text-gray-700 truncate">{url}</p>
        ) : (
          // 4. 显示文件列表
          <ul className="list-disc list-inside space-y-1">
            {files.map((file) => (
              <li key={file.name} className="text-sm text-gray-700 truncate">
                {file.webkitRelativePath || file.name}
              </li>
            ))}
          </ul>
        )}
      </div>
    </div>
  );
}
